// import jsonp from 'common/js/jsonp.js'
import axios from 'axios'

/* eslint-disable */
function getRandomCallBackName () {
  return '__jp' + String(Math.random()).slice(2, 8)
}
// 获取 主页数据
// export function getHomeList (pastNum = 20) {
//   const url = 'https://m.smzdm.com/ajax_home_list_show'
//   let randCallbackName = getRandomCallBackName()
//   let params = Object.assign({}, {}, {
//     callback: randCallbackName,
//     jsonpCallback: randCallbackName,
//     timesort: new Date().getTime(),
//     past_num: pastNum
//   })
//   return jsonp(url, params, { name: randCallbackName })
// }

// let homeReqFlag = false


// 获取 主页swpier数据
export function getHomeSwiper () {
  const url = '/apizdm/home-swiper'
  return axios.get(url, {
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取 主页数据
export function getHomeList (pastNum, mountedTimestamp) {
  var timestampNow = new Date().getTime()
  let resetStartTime = mountedTimestamp - 1000000
  let delatTime = (timestampNow - mountedTimestamp) * 300 * 500
  var reTimestamp = resetStartTime - delatTime
  reTimestamp = '' + reTimestamp
  var timesort = reTimestamp.substr(0, reTimestamp.length - 1)
  const url = '/apizdm/home-list'
  const data = Object.assign({}, {
    timesort: timesort,
    past_num: pastNum
  })
  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}
